<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>H+ 后台主题UI框架 - 空白页</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

  <link rel="shortcut icon" href="favicon.ico">
    <link href="__STATIC__/layout/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/layout/css/font-awesome.css?v=4.4.0" rel="stylesheet">
     <link href="__STATIC__/layout/css/plugins/summernote/summernote.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/summernote/summernote-bs3.css" rel="stylesheet">
     <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/plugins/webuploader/webuploader.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/demo/webuploader-demo.css">
    <!-- jqgrid-->
    <link href="__STATIC__/layout/css/animate.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
    <style>
        .hide_table{display: none;}
    </style>
</head>

<body style="color:#333;padding:3px;">
<form method="post" class="form-horizontal" enctype="multipart/form-data" id="f1">
        <input type="hidden" name="type" id="type"/>
        <input type="hidden" name="tid" value="{$apply.id}"/>
    <!-- 标题 -->
      <div class="page-heade">
       <h2 class="title_color text-center">集团TI销售目标异动</h2>
    </div>
    <!-- 标题 -->
       
    <div class="form-horizontal">
      <table class="row-margin-top tab-content table-bordered table text-center" border="1">
          <thead>
          <tr>
            <td style="width:150px">主题：</td>
            <td class="text-left" ><input type="text" class="form-control"  value="{$apply.title}" name="title"/></td>
          </tr>
        
           <tr>
            <td style="width:150px">申请单编号：</td>
            <td class="text-left" >{$apply.no}</td>
          </tr>

          <tr>
            <td colspan="2" class="text-left">
              <input type="button" class="btn btn-w-m btn-info" id="dr" value="导入数据"/>
                    
                  <span>(至少导入一条预算明细)</span>
               <input type="button" class="btn btn-w-m btn-info" id="dc" tid="{$apply.id}" value="导出数据"/>
            </td>
          </tr>
          </thead>
          <tbody id="tb" style="display:none;">
              <tr>
                 <td class="text-left">
                 选择导入的文件:
                 </td>
                 <td><input type="file" name="wenjian" id="drfile"/></td>
              </tr>
              <tr>
                   <td colspan="2" class="text-left" style="font-size: 12px;">
                   <span style="color:red;">温馨提示:如果导入过程中出现未满足系统要求的数据，则整份导入资料都无法导入，必须按照系统给出的信息提示修改导入资料，并重新上传</span><br/>
                   <b>Excel文件注意事项:</b><br/>
                   1.请仔细阅读下面的TI销售目标导入格式，并按照注意事项填入正确的数据<br/>
                   2.若设置一级渠道，则一级渠道不能为空，且必须是系统中存在的一级渠道<br/>
                   3.若设置二级渠道，则二级渠道不能为空，且必须是系统中存在的二级渠道<br/>
                   4.若设置分区，则分区不能为空，且必须是系统中存在的分区<br/>
                   5.若设置省份，则省份不能为空，且必须是系统中存在的省份<br/>
                   6.若设置城市，则城市不能为空，且必须是系统中存在的城市<br/>
                   7.若设置经销商，则经销商不能为空，且必须是系统中存在的经销商<br/>
                   8.若设置系统，则系统不能为空，且必须是系统中存在的系统<br/>
                   9.若设置网点，则网点不能为空，且必须是系统中存在的网点<br/>
                   10.若设置品牌，则品牌不能为空，且必须是系统中存在的品牌<br/>
                   11.若设置品类，则品类不能为空，且必须是系统中存在的品类<br/>
                   12.若设置系列，则系列不能为空，且必须是系统中存在的系列<br/>
                   13.若设置SKU，则SKU不能为空，且必须是系统中存在的SKU<br/>
                   14.若设置单品，则单品不能为空，且必须是系统中存在的单品<br/>
                   15.若设置一级科目，则一级科目不能为空，且必须是系统中存在的一级科目<br/>
                   16.若设置二级科目，则二级科目不能为空，且必须是系统中存在的二级科目<br/>
                   17.若设置费用明细科目，则费用明细科目不能为空，且必须是系统中存在的费用明细科目<br/>
                   18.毛销售金额不能为空<br/>
                   19.若设置净销售金额，则净销售金额不能为空<br/>
                   20.若设置净利润目标，则净利润不能为空<br/>
                   21.若设置财年，则财年不能为空，且必须是系统中存在的财年<br/>
                   22.若设置一级考核期，则一级考核期不能为空，且必须是系统中存在的一级考核期<br/>
                   23.若设置二级考核期，则二级考核期不能为空，且必须是系统中存在的二级考核期<br/>
                   <b>Excel文件导入格式:</b><a href="{:url('Xitongexcel/jituan_daochu')}">Ti销售目标导入格式.xls</a><span style="color:red;">Excel中标记为红色底色的列都为必填项</span>
                   </td>
              </tr>
          </tbody>
          <tfoot>
          <tr>
            <td colspan="2" class="text-left">
              <label style="padding-top: 0" class="col-sm-1 control-label">备注：</label>
                  <div class="col-sm-10">
                      <textarea style="height: 100px;" maxlength="500" name="remark" class="form-control">{$apply.remark}</textarea>
                  </div>
            </td>
          </tr>
          </tfoot>
      </table>
      <div class="container-fluid">
        <a href="javascript:;" class="btn btn-outline btn-primary cbtn" onclick="fanka(0)">查看详情</a>
         <a href="javascript:;" class="btn btn-outline btn-primary cbtn" onclick="fanka(1)">按产品纬度查看</a>
        <a href="javascript:;" class="btn btn-outline btn-primary cbtn" onclick="fanka(2)">按费用纬度查看</a>
       <a href="javascript:;" class="btn btn-outline btn-primary cbtn" onclick="fanka(3)">按渠道纬度查看</a>
       <a href="javascript:;" class="btn btn-outline btn-primary cbtn" onclick="fanka(4)">按客户纬度查看</a>
        
      <!--详情-->
         <table class="table row-margin-top table-bordered bud_hei table-hover hide_table">
            <tr class="info">
                <th>明细编号</th>
                <th>一级渠道</th>
              	<th>分区</th>
              	<th>省份</th>
                <th>城市</th>
               <th>经销商</th>
               <th>产品品牌</th>
               <th>一级费用科目</th>
               <th>二级费用科目</th>
                <th>财年</th>
                <th>一级考核期</th>
               <th>二级考核期</th>
                <th>毛销售金额(元)</th>
                <th>净销售金额(元)</th>
                <th>利润目标金额(元)</th>
            </tr>
     		{volist name="detail" id="vod"}
          <tr>
          <td>{$apply.no}_{$vod.detail_no}</td>
          <td>{$vod.channel1}</td>
          <td>{$vod.fenqu}</td>
          <td>{$vod.sheng}</td>
          <td>{$vod.shi}</td>
          <td>{$vod.jingxiao}</td>
          <td>{$vod.pinpai}</td>
          <td>{$vod.yijifeiyong}</td>
          <td>{$vod.erjifeiyong}</td>
          <td>{$vod.cainian}</td>
          <td>{$vod.yijikaoheqi}</td>
          <td>{$vod.erjikaoheqi}</td>
          <td>{$vod.sale}</td>
          <td>{$vod.sale_real}</td>
          <td>{$vod.profit}</td>
          </tr>
        {/volist}
      </table> 
      <!--详情-->
      <!--产品-->
         <table class="table row-margin-top table-bordered bud_hei hide_table">
          <tr class="info text-center">
            <th>产品品牌</th>
           {volist name="ck" id="vock"}
              <th>{$vock.kaoheqi}({$vock.cainian})</th>
            {/volist}
          
            <th>合计</th>
          </tr>
 
          {volist name="pro" id="voq"}
            <tr class="ned_tr">
        <td>{$voq.pinpai}</td>
        {volist name="ck" id="voc1"}
          <td>
                {volist name="prode" id="voqd1"}
                  {if condition="($voqd1.pinpai eq $voq.pid) and ($voqd1.cainian eq $voc1.cid) and ($voqd1.kaoheqi eq $voc1.kid)"}
                  {$voqd1.f}
                  {/if}
                {/volist}
                </td>
              {/volist}
              <td>{$voq.f}</td>
            </tr>
          {/volist}
          <tr class="warning">
            <td class="text-left"  headers="">销售额总计：</td>
            {for start="1" end="$kc"}
        <td tag="{$i}" class='ned_td'></td>
      {/for}
            <td>{$sumpro}</td>
          </tr>
          
      </table>
      <!--产品-->
      <!--费用-->
        <table class="table row-margin-top table-bordered bud_hei hide_table">
           <tr class="info text-center">
            <th>一级费用科目</th>
          <th>二级费用科目</th>
           {volist name="ck" id="vock"}
              <th>{$vock.kaoheqi}({$vock.cainian})</th>
            {/volist}
            <th>合计</th>

          </tr>
          
          {volist name="feiyong" id="voq"}
            <tr class="nef_tr">
        <td>{$voq.yijifeiyong}</td>
        <td>{$voq.erjifeiyong}</td>
        {volist name="ck" id="voc1"}
          <td>
                {volist name="feiyongde" id="voqd1"}
                  {if condition="($voqd1.yijifeiyong eq $voq.c1id) and ($voqd1.erjifeiyong eq $voq.c2id) and ($voqd1.cainian eq $voc1.cid) and ($voqd1.kaoheqi eq $voc1.kid)"}
                  {$voqd1.f}
                  {/if}
                {/volist}
                </td>
              {/volist}
              <td>{$voq.f}</td>
            </tr>
          {/volist}
          <tr class="warning">
            <td class="text-left"  colspan="2" headers="">销售额总计：</td>
            {for start="1" end="$kc"}
        <td tag="{$i}" class='nef_td'></td>
      {/for}
            <td>{$sumfeiyong}</td>
          </tr>
           
          
      </table>
      <!--费用-->
<!--渠道-->
        <table class="table row-margin-top table-bordered bud_hei hide_table">
            <tr class="info text-center">
            <th>一级渠道</th>
           {volist name="ck" id="vock"}
              <th>{$vock.kaoheqi}({$vock.cainian})</th>
            {/volist}
          
            <th>合计</th>
          </tr>
       {volist name="qudao" id="voq"}
            <tr class="neq_tr">
        <td>{$voq.title}</td>
        {volist name="ck" id="voc1"}
          <td>
                {volist name="qudaode" id="voqd1"}
                  {if condition="($voqd1.channel1 eq $voq.channel1) and ($voqd1.cainian eq $voc1.cid) and ($voqd1.kaoheqi eq $voc1.kid)"}
                  {$voqd1.f}
                  {/if}
                {/volist}
                </td>
              {/volist}
              <td>{$voq.f}</td>
            </tr>
          {/volist}
          <tr class="warning">
            <td class="text-left"  headers="">销售额总计：</td>
            {for start="1" end="$kc"}
        <td tag="{$i}" class='neq_td'></td>
      {/for}
            <td>{$sumqudao}</td>
          </tr>

      </table>
      <!--渠道-->
   <!--客户-->
        <table class="table row-margin-top table-bordered bud_hei hide_table">
            <tr class="info text-center">
            <th>经销商</th>
           {volist name="ck" id="vock"}
              <th>{$vock.kaoheqi}({$vock.cainian})</th>
            {/volist}
          
            <th>合计</th>
          </tr>
       {volist name="client" id="voq"}
            <tr class="nec_tr">
        <td>{$voq.title}</td>
        {volist name="ck" id="voc1"}
          <td>
                {volist name="clientde" id="voqd1"}
                  {if condition="($voqd1.jingxiao eq $voq.jingxiao) and ($voqd1.cainian eq $voc1.cid) and ($voqd1.kaoheqi eq $voc1.kid)"}
                  {$voqd1.f}
                  {/if}
                {/volist}
                </td>
              {/volist}
              <td>{$voq.f}</td>
            </tr>
          {/volist}
          <tr  class="warning">
            <td class="text-left" headers="">销售额总计：</td>
            {for start="1" end="$kc"}
        <td tag="{$i}" class='nec_td'></td>
      {/for}
            <td>{$sumclient}</td>
          </tr>

      </table>

      <!--客户-->
        <table class="table table-bordered text-left bud_hei">
            <tr class="info">
                <th class="text-left font-bold">审批意见</th>
            </tr>
            {volist name="logs" id="l"}
          <tr>
              <td>{$l.USERNAME} 审批动作：{$l.MEMO}；审批意见：{if $l.COMMENTS}{$l.COMMENTS}{else/}无{/if}(审批时间：{$l.ACTIONTIME})</td>
          </tr>
          
          {/volist}
      </table>
     <div class="form-group white-bg" style="margin:20px 10px 20px 20px;">
            <div id="uploader" class="wu-example">
                <!--用来存放文件信息-->
                <div id="thelist" class="uploader-list">
                  
                </div>
                <div class="btns">
                    <div id="picker">选择文件</div>
                    <button id="ctlBtn" class="btn btn-default">开始上传</button>
                </div>
                <input type="hidden" name="attach" id="attach"  >
            </div>
            <span>注：最多上传15个文件，每个文件小于50M,支持格式：</span><br>jpg,bnp,gif,png,jpeg,tif,raw,doc,docx,xls,xlsx,ppt,pptx,txt,pdf,rar,zip,mp4,avi,rmvb,rm,mid,3gp,AVI,3GP,,mpg,mp3,wma,wav
        </div>
     
       <div class="hr-line-dashed"></div>
              <div class="container-fluid text-center  padding-10">
                <input class="btn btn-w-m btn-warning" type="button" id="caogao" value="保存为草稿">
                <input class="btn btn-w-m btn-primary" type="button" id="tijiao" value="保存并提交流程">
                <input class="btn btn-w-m btn-default" type="button" id="back" name="" value="返回">
              </div>
    </div>
       {if condition="$apply.tag eq 1"}
       <div class="SuccessImg font-bold">
        申报已异动
      </div>
    {/if}
     {if condition="$apply.tag neq 1 and $apply.state eq 7"}
        <div class="applyImg font-bold">
        申报已生效
      </div>
    {/if}
     </form>
    <!-- 全局js -->
    <script src="__STATIC__/layout/js/jquery.min.js?v=2.1.4"></script>
    <script src="__STATIC__/layout/js/bootstrap.min.js?v=3.3.6"></script>
    <!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
    <script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
    <!-- <script src="js/plugins/layer/layer.min.js"></script> -->

    <!-- 自定义js -->
    <!-- <script src="js/hplus.js?v=4.1.0"></script> -->
    <!-- <script type="text/javascript" src="js/contabs.js"></script> -->
     <!-- Peity -->
    <script src="__STATIC__/layout/js/plugins/peity/jquery.peity.min.js"></script>

    <!-- jqGrid -->
    <script src="__STATIC__/layout/js/plugins/jqgrid/i18n/grid.locale-cn.js?0820"></script>
    <script src="__STATIC__/layout/js/plugins/jqgrid/jquery.jqGrid.min.js?0820"></script>

    <!-- 自定义js -->
    <script src="__STATIC__/layout/js/content.js?v=1.0.0"></script>
     <script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
    
    <!-- ztree -->
    <script type="text/javascript" src="__STATIC__/layout/js/jquery.ztree.core.js"></script>
    <script type="text/javascript" src="__STATIC__/layout/js/jquery.ztree.excheck.js"></script>
    <!-- <script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script> -->
    <!--统计代码，可删除-->
    <script src="__STATIC__/layout/js/plugins/layer/laydate/laydate.js"></script>
    <script>
    var tag={$apply.tag};
       //提交处理
        $("#caogao").click(function(){
          //保存类型设为草稿
          $("#type").val(1);
            if(tag==2){
                  swal({
                            title: "提示",
                            text: "已经存在了对此单的异动申请，如继续申请，则取消之前的异动申请，是否继续？",
                            type: "warning",
                            showCancelButton: true,
                            confirmButtonColor: "#FF3333",
                            confirmButtonText: "继续",
                            cancelButtonText: "取消",
                            closeOnConfirm: true
                        },
                        function (isConfirm) {
                           if (isConfirm) {
                            go_submits();
                           }
                        })
                }else{

                  
                go_submits();
                }
        })
        $("#tijiao").click(function(){
          //保存类型设为草稿
          $("#type").val(3);
            if(tag==2){
                  swal({
                            title: "提示",
                            text: "已经存在了对此单的异动申请，如继续申请，则取消之前的异动申请，是否继续？",
                            type: "warning",
                            showCancelButton: true,
                            confirmButtonColor: "#FF3333",
                            confirmButtonText: "继续",
                            cancelButtonText: "取消",
                            closeOnConfirm: true
                        },
                        function (isConfirm) {
                           if (isConfirm) {
                            go_submits();
                           }
                        })
                }else{

                  
                go_submits();
                }
        })
         //ajax提交
        function go_submits(){
           var formData = new FormData($('#f1')[0]);  
         $.ajax({    
              url: '{:url("Jituanmubiao/yd_jt_add")}' ,  /*这是处理文件上传的servlet*/  
              type: 'POST',    
              data: formData,   
              cache: false,    
             contentType: false,  
              processData: false,  
              success: function (re) {  
              //alert(re);  
                 if(re!=""){
                var jieguo=JSON.parse(re);
                  if(jieguo["state"]==1){
                    swal({
              title: "完成",
              text:  jieguo["msg"],
              type: "success"
              },function(){
                location.href="{:url('Jituanmubiao/manage')}";
              });
                  }else{
                  swal({
            title: "错误",
            text:  jieguo["msg"],
            type: "warning"
            });
                  }
                  
                }else{
                   swal({
            title: "错误",
            text:  "系统繁忙请稍后再试",
            type: "warning"
            });
                }
              },    
              error: function (re) {    
                  swal({
            title: "错误",
            text:  "系统繁忙请稍后再试",
            type: "warning"
            });
              }    
         });    
        }
    $("#back").click(function(){
      location.href="{:url('manage')}";
    })
    $("#dr").click(function(){
      $("#tb").show();
    })
    $("#dc").click(function(){
      location.href="{:url('daochu')}?tid="+$(this).attr("tid");
    })
        //默认第一个选项卡选中
        $(".cbtn").eq(0).addClass("active");
        $(".hide_table").eq(0).show();

        function fanka(i){
            $(".cbtn").removeClass("active");
            $(".hide_table").hide();

            $(".cbtn").eq(i).addClass("active");
            $(".hide_table").eq(i).show();
        }
        $(".ned_td").each(function(){
        	var index=$(this).attr("tag");
        	var he=0;
        	$(".ned_tr").each(function(){
        		if(!isNaN(parseFloat($(this).children().eq(index).html())))
        			he+=parseFloat($(this).children().eq(index).html());
        	})
        	$(this).html(he);
        })
         $(".nef_td").each(function(){
        	var index=$(this).attr("tag")*1+1;
        	var he=0;
        	$(".nef_tr").each(function(){
        		if(!isNaN(parseFloat($(this).children().eq(index).html())))
        			he+=parseFloat($(this).children().eq(index).html());
        	})
        	$(this).html(he);
        })
           $(".neq_td").each(function(){
        	var index=$(this).attr("tag");
        	var he=0;
        	$(".neq_tr").each(function(){
        		if(!isNaN(parseFloat($(this).children().eq(index).html())))
        			he+=parseFloat($(this).children().eq(index).html());
        	})
        	$(this).html(he);
        })
            $(".nec_td").each(function(){
        	var index=$(this).attr("tag");
        	var he=0;
        	$(".nec_tr").each(function(){
        		if(!isNaN(parseFloat($(this).children().eq(index).html())))
        			he+=parseFloat($(this).children().eq(index).html());
        	})
        	$(this).html(he);
        })
    </script>
      <script type="text/javascript">
    // 添加全局站点信息
    var BASE_URL = '__STATIC__/layout/js/plugins/webuploader';
</script>
<script src="__STATIC__/layout/js/plugins/webuploader/webuploader.min.js"></script>
<script type="text/javascript">
   // 文件上传
    jQuery(function() {
        var $ = jQuery,
            $list = $('#thelist'),
            $btn = $('#ctlBtn'),
            state = 'pending',
            uploader;

        var ids = [];
        uploader = WebUploader.create({

            // 不压缩image
            resize: false,

            // swf文件路径
            swf: BASE_URL + '/js/Uploader.swf',

            // 文件接收服务端。
            server: '{:url("upload/fileupload")}',

            // 选择文件的按钮。可选。
            // 内部根据当前运行是创建，可能是input元素，也可能是flash.
            pick: '#picker'
        });

        // 当有文件添加进来的时候
        uploader.on( 'fileQueued', function( file ) {
            $list.append( '<div id="' + file.id + '" class="item">' +
                '<h4 class="info">' + file.name + '</h4>' +
                '<p class="state">等待上传...</p>' +
                '</div>' );
        });

        // 文件上传过程中创建进度条实时显示。
        uploader.on( 'uploadProgress', function( file, percentage ) {
            var $li = $( '#'+file.id ),
                $percent = $li.find('.progress .progress-bar');

            // 避免重复创建
            if ( !$percent.length ) {
                $percent = $('<div class="progress progress-striped active">' +
                    '<div class="progress-bar" role="progressbar" style="width: 0%">' +
                    '</div>' +
                    '</div>').appendTo( $li ).find('.progress-bar');
            }

            $li.find('p.state').text('上传中');

            $percent.css( 'width', percentage * 100 + '%' );
        });

        uploader.on( 'uploadSuccess', function( file,response) {
            if(response.success)
                ids.push(response.id)
            $( '#'+file.id ).find('p.state').text(response.msg);
        });

        uploader.on( 'uploadError', function( file ) {
            $( '#'+file.id ).find('p.state').text('上传出错');
        });

        uploader.on( 'uploadComplete', function( file ) {
            $('#attach').val(ids.join(','))
            $( '#'+file.id ).find('.progress').fadeOut();
        });

        uploader.on( 'all', function( type ) {
            if ( type === 'startUpload' ) {
                state = 'uploading';
            } else if ( type === 'stopUpload' ) {
                state = 'paused';
            } else if ( type === 'uploadFinished' ) {
                state = 'done';
            }

            if ( state === 'uploading' ) {
                $btn.text('暂停上传');
            } else {
                $btn.text('开始上传');
            }
        });

        $btn.on( 'click', function() {
            if ( state === 'uploading' ) {
                uploader.stop();
            } else {
                uploader.upload();
            }
            return false
        });
     })

</script>
</body>

</html>
